package whf.framework.quartz;

import java.util.List;

import whf.framework.log.Log;
import whf.framework.log.LogFactory;
import whf.framework.mail.entity.Mail;
import whf.framework.mail.service.MailService;

/**
 * 发送邮件任务服务
 * @author wanghaifeng
 * @create Oct 19, 2006 2:35:07 PM
 * 
 */
public class MailSenderJob {
	private static Log log = LogFactory.getLog(MailSenderJob.class);
	
	private MailService mailService;
	
	public void setMailService(MailService service){
		this.mailService = service;
	}
	
	public void send(){
		try{
			List<Mail> mails = this.mailService.findNotSentMails();
			for(Mail m: mails){
				this.mailService.send(m);
			}
		}catch(Exception e){
			log.error(this, e);
		}
	}
}
